package com.zwb.demo.easyweb.modules.menu;

import com.zwb.demo.easyweb.common.entity.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * 系统菜单表
 *
 * @author zwb
 * @date 2020-04-30T11:20:54.324554900
*/
@RestController
@Api(value = "系统菜单表接口" ,description = "系统菜单表接口")
public class SysMenuController {

    private final SysMenuService sysMenuService;


    @Autowired
    public SysMenuController(SysMenuService sysMenuService) {
        this.sysMenuService = sysMenuService;
    }

    @GetMapping("/system/menu")
    @ApiOperation(value = "查询所有系统菜单表")
    public ResponseResult findAll(){
        return sysMenuService.findAll();
    }

    @PutMapping("/system/menu")
    @ApiOperation(value = "新增或修改系统菜单表")
    public ResponseResult saveOne(@RequestBody SysMenuVO vo){
        return sysMenuService.saveOne(vo);
    }

    @DeleteMapping("/system/menu/{uuid}")
    @ApiOperation(value = "删除系统菜单表")
    public ResponseResult deleteOne(@PathVariable String uuid){
        return sysMenuService.deleteOne(uuid);
    }

    @GetMapping("/system/menu/root")
    @ApiOperation(value = "查询所有系统根菜单表")
    public ResponseResult findAllRootMenu(){
        return sysMenuService.findAllRootMenu();
    }

    @GetMapping("/system/root/{uuid}/menus")
    @ApiOperation(value = "查询所有系统根菜单表")
    public ResponseResult findAllMenuByRoot(@PathVariable String uuid){
        return sysMenuService.findAllMenuByRoot(uuid);
    }
}
